<template>
	<view class="test">
		<view class="child" v-for="(item,index) in test" :ley="index">
			<view class="title_box">
				<view class="title">{{item.title}}</view>
				<view class="times">时长：{{item.pass_score}}分钟{{show}}</view>
			</view>
			<view class="cont">
				<view>题目总数：{{item.question_count}}</view>
				<view>总分数：{{item.total_score}}</view>
				<view>及格分：{{item.expire}}</view>
			</view>
			<view class="bottom">
				<u-button type="success" v-if="!item.is_test" @click="Totest(item.id)">开始考试</u-button>
				<u-button type="success" v-if="item.is_test" :disable="item.is_test">您已考过</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import { getTest, } from "../../http/api.js";
	export default {
		data() {
			return {
				params:{
					page:1,
					limit:5
				},
				test:[],
				show:false,
				content:'chao!!',
			};
		},
		onLoad() {
			
		},
		onShow() {
			this.getList();
		},
		methods:{
			async getList(){
				let data = await getTest(this.params);
				console.log(data);
				if(data.code === 20000){
					this.test = data.data.rows;
				};
				// console.log(this.test);
			},
			Totest(id){
				uni.showModal({
					content: '是否要开始考试',
					success: function (res) {
						if (res.confirm) {
							console.log(id);
							uni.navigateTo({
								url:"../test-list/test-list?id="+id
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				
			},
		},
	}
</script>

<style lang="scss">
	.test{
		width: 100%;
		.child{
			border-top: 15rpx solid #DCDCDC;
			box-sizing: border-box;
			.title_box{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				padding: 25rpx;
				.title{
					font-weight: bold;
				}
				.times{
					color: red;
					font-size: 24rpx;
				}
			}
			.cont{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				border-bottom: 2rpx solid #ccc;
				padding: 20rpx;
				padding-bottom: 30rpx;
			}
			.bottom{
				// display: flex;
				height: 80rpx;
				padding: 20rpx;
				.u-button{
					float: right;
					width: 180rpx;
					font-size: 30rpx;
				}
			}
		}
		.child:first-child{
			border: 0;
		}
	}
</style>
